using System;
using System.Windows.Controls;

namespace FluentSilverlight.Expressions.Lists
{
    public class ListBoxExpression<TModel> : ItemsControlExpression<ListBoxExpression<TModel>, TModel>
        where TModel : class 
    {
        public ListBoxExpression(TModel model)
            : this(model, string.Format("ListBox_{0}", Guid.NewGuid()))
        {
        }

        public ListBoxExpression(TModel model, string name) : base(model, name)
        {
        }

        public static implicit operator ListBox(ListBoxExpression<TModel> expression)
        {
            var lb = new ListBox();
            expression.BuildUp(lb);
            return lb;
        }

        protected override ListBoxExpression<TModel> thisInstance()
        {
            return this;
        }
    }
}